<?php

class Auth extends Controller {
	function Auth() {
		parent::Controller();
	}
	
	function index() {
		// need to tidy url if re-directed from check() function
		$data['content'] = array('auth/form');
		$this->load->view('includes/template', $data);
	}
	
	function check() {
		$result = $this->auth_model->validate();
		
		if ($result) {
			// logged in
			$data = array(
				'username' => $this->input->post('username'),
				'is_logged_in' => TRUE
			);
			
			$this->session->set_userdata($data);
			redirect('newsfeed/select');
		} else {
			// not logged in
			$this->index();
		}
	}
	
	function logout() {
		$this->session->sess_destroy();
		$this->index();
	}
	
	function help() {
		$data['content'] = array('auth/help');
		//$data['main_content'] = 'auth/help';
		$this->load->view('includes/template', $data);
	}
}
?>